<template>
    <FormItem :label-width="10">
        <Button v-if="showBtn('查询')" type="primary" @click="handleSubmitClick(formName)">查询</Button>
        <Button class="ivu-ml-8" @click="handleResetClick(formName)">清空</Button>
        <a v-if="isShowFold" v-font="14" class="ivu-ml-8" @click="handleChange">
            <template v-if="!isCollapse">
                展开 <Icon type="ios-arrow-down" />
            </template>
            <template v-else>
                收起 <Icon type="ios-arrow-up" />
            </template>
        </a>
    </FormItem>
</template>
<script>
    import { mapGetters } from 'vuex';
    import util from '@/libs/util';
    import { getBtnsId } from '@/libs/btnsPermission'
    export default {
        // mixins: [permissions],
        props: {
            isCollapse: {
                type: Boolean
            },
            isShowFold: {
                type: Boolean,
                default: true
            },
            formName: {
                type: String
            }
        },
        data () {
            return {
                util: util,
                collapse: false,
                curMenuBtns: '',
                systematicBtns: []
            }
        },
        created () {
            this.collapse = this.isCollapse;
        },
        computed: {
            ...mapGetters('permissions/systemBtns', [
                'showBtn'
            ]),
        },
        methods: {
            // 展开收缩数据
            handleChange () {
                this.collapse = !this.collapse;
                this.$emit('collapseChange', this.collapse);
            },
            // 表格列表筛选件提交
            handleSubmitClick (name) {
                let curBtnId = getBtnsId('查询')
				sessionStorage.setItem('buttonId', curBtnId)
                this.$emit('handleSubmit', name);
            },
            // 表格列表筛选件清空
            handleResetClick (name) {
                window.localStorage.removeItem('categoryUuid')
                window.localStorage.removeItem('selectValue')
                util.Pub.setStorageSync('storeName', '')
                util.Pub.setStorageSync('productName', '')
                util.Pub.setStorageSync('productNo', '')
                util.Pub.setStorageSync('canDistribute', '')
                util.Pub.setStorageSync('state', '')
                util.Pub.setStorageSync('brandName', '')
                util.Pub.setStorageSync('categoryUuid', '')
                window.localStorage.removeItem('settlement')
                window.localStorage.removeItem('commission')
                this.$emit('handleReset', name);
            }
        }
    }
</script>
